package com.vip.common.util;

import com.vip.common.entity.SysLog;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 使用postgre数据库驱动直连数据库
 *
 * @author wgb
 * @date 2020/3/13 17:42
 */
public class PostgreJdbcUtils {
    /**
     * 获取数据库连接
     *
     * @return PostgreSQL连接
     */
    public static Connection getConnection(String driver, String url, String username, String password) {
        Connection conn = null;
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, username, password);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return conn;
    }
    public static void closeConncetion(Connection conn, Statement stat) {
        try {
            stat.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
